package com.cadre.web.controller.officer;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cadre.common.utils.R;
import com.cadre.common.utils.SecurityUtils;
import com.cadre.common.utils.annotation.A19Tag;
import com.cadre.common.utils.annotation.SysLog;
import com.cadre.common.utils.common.GenerateUUID;
import com.cadre.common.utils.common.HttpContextUtils;
import com.cadre.common.utils.common.IPUtils;
import com.cadre.common.utils.oldutil.DateUtil;
import com.cadre.system.domain.officer.*;
import com.cadre.system.domain.vo.ESUtil;
import com.cadre.system.service.*;
import com.cadre.web.controller.tool.TestTextUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

@Api(value = "简历Controller", tags = {"干部简历接口"})
@RequestMapping({"/profess/a19"})
@RestController
public class A19Controller {
    @Resource
    private A01Service a01Service;
    @Resource
    private A19Service a19Service;
    @Resource
    private DIC_ZBService dIC_ZBService;
    @Resource
    private SysLogService sysLogService;
    @Resource
    private A93Service a93Service;
    @Resource
    private B01Service b01Service;
    @Autowired
    private UnitInfoService unitInfoService;
    @Autowired
    private A79Service a79Service;
    @Autowired
    RestHighLevelClient client;

    @GetMapping({"/list"})
    @ApiOperation("获取简历列表")
    public R list(@RequestParam Map<String, Object> params) {
        return R.ok().put("page", (Object) this.a19Service.queryPage(params));
    }

    @GetMapping({"/mlist"})
    @ApiOperation("获取简历列表")
    public R mlist(String personid, Integer a1935) {
        Map<String, Object> map = new HashMap<>();
        map.put("personid", personid);
        if (a1935.intValue() == 0 || a1935.intValue() == 1) {
            map.put("a1935", a1935);
        }
        List<A19> list = this.a19Service.selectByList(map);
        if (list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                Map<String, Object> bsmap = new HashMap<>();
                bsmap.put("b0101", list.get(i).getA1916());
                List<B01> b01list = this.b01Service.selectByMaps(bsmap);
                if (b01list.size() > 0) {
                    list.get(i).setB0103(b01list.get(0).getB0103());
                }
            }
        }
        return R.ok().put("data", (Object) list);
    }

    @GetMapping({"/getAddr"})
    @ApiOperation("获取学历字典")
    public R getAddr() {
        Map<String, Object> map = new HashMap<>();
        map.put("tableName", "DIC_ZB01");
        return R.ok().put("data", (Object) this.dIC_ZBService.getAllForTree(map));
    }

    @GetMapping({"/getAddrByName"})
    @ApiOperation("模糊查询学历字典")
    public R getAddrByName(@RequestParam String name) {
        Map<String, Object> map = new HashMap<>();
        map.put("tableName", "DIC_ZB01");
        map.put("name", name);
        return R.ok().put("data", (Object) this.dIC_ZBService.getAllForTree(map));
    }

    @GetMapping({"/info/{flowId}"})
    @ApiOperation("获取简历信息")
    public R info(@PathVariable("flowId") String flowId) {
        return R.ok().put("a19", (Object) ((A19) this.a19Service.getBaseMapper().selectById(flowId)));
    }

    @PostMapping({"/save"})
    @SysLog(value = "新增现职信息", target = "A01", set = "A19", type = 0)
    @ApiOperation("添加简历")
    @A19Tag("更新")
    public R save(@RequestBody A19 a19) {
        a19.setFlowid(GenerateUUID.getUUID());
        if (a19.getA1956() == null) {
            a19.setA1956((short) 999);
        }
        this.a19Service.getBaseMapper().insert(a19);
        return R.ok();
    }

    @PostMapping({"/update"})
    @SysLog(value = "修改现职信息", target = "A01", set = "A19", type = 1)
    @ApiOperation("简历更新")
    @A19Tag("更新")
    public R update(@RequestBody A19 a19) {
        if (a19.getA1956() == null) {
            a19.setA1956((short) 999);
        }
        if (this.a19Service.updateByPrimaryKeySelective(a19) == 1) {
            return R.ok();
        }
        return R.error();
    }

    private void updateA0177b(A19 a19) {
        String xz = "";
        new SimpleDateFormat(DateUtil.MONTG_DATE_FORMAT);
        Map<String, Object> map = new HashMap<>();
        map.put("personid", a19.getPersonid());
        map.put("a1935", 1);
        for (A19 a192 : this.a19Service.selectByList(map)) {
            if (xz.equals("")) {
                xz = a192.getA1916() + a192.getA1920();
            } else {
                xz = xz + ',' + a192.getA1916() + a192.getA1920();
            }
        }
        this.a19Service.update_A01_A0177b((A01) this.a01Service.getBaseMapper().selectById(a19.getPersonid()), xz);
    }

    private void update_A01(A19 a19) {
        Date a1905 = this.a19Service.selectMaxA1905(a19.getPersonid());
        String a1930 = this.a19Service.selectMaxA1930(a19.getPersonid());
        String a1970 = this.a19Service.selectMaxA1970(a19.getPersonid());
        A01 a01 = this.a01Service.selectByPrimaryKey(a19.getPersonid());
        a01.setA0179(a1930);
        a01.setA0198(a1970);
        a01.setA0185(a1905);
        this.a01Service.updateXianz(a01);
    }

    @GetMapping({"/updateResumeByPerson"})
    @ApiOperation("手动更新简历")
    public R updateResumeByPerson(@RequestParam String personid, @RequestParam String a0177b) {
        A01 entity = (A01) this.a01Service.getBaseMapper().selectById(personid);
        entity.setA0177b(a0177b);
        this.a01Service.updateById(entity);
        return R.ok();
    }

    @PostMapping({"/updateA19/{personid}"})
    @ApiOperation("简历批量更新(2版)")
    public R updateA19(@RequestBody List<A19> entityList, @PathVariable("personid") String personid) throws IOException {
        List<String> list = new ArrayList<>();
        List<A19> listA19 = new ArrayList<>();
        List<A19> listA19ES = new ArrayList<>();
        if (!(personid == null || personid == "")) {
            listA19 = this.a19Service.getBaseMapper().selectList(new LambdaQueryWrapper<A19>().eq(A19::getPersonid, personid));
        }
        if (entityList.size() > 0) {
            if (!(personid == null || personid == "")) {
                this.a19Service.deleteByPersonid(personid);
                this.a79Service.deleteA79AByPersonidA(personid);
            }
            for (int i = 0; i < entityList.size(); i++) {
                entityList.get(i).setFlowid(GenerateUUID.getUUID());
                if (entityList.get(i).getA1956() == null) {
                    entityList.get(i).setA1956((short) 999);
                }
                this.a19Service.getBaseMapper().insert(entityList.get(i));
                listA19ES.add(entityList.get(i));
                list.add(entityList.get(i).getA1915());
            }
            this.a79Service.updateA79A(entityList.get(0));
        } else if (!(personid == null || personid == "")) {
            this.a19Service.deleteByPersonid(personid);
        }
        for (int n = 0; n < listA19.size(); n++) {
            list.add(listA19.get(n).getA1915());
        }
        List<String> list2 = (List) list.stream().distinct().collect(Collectors.toList());
        for (int m = 0; m < list2.size(); m++) {
            this.unitInfoService.initB01ActualByUnitid(list2.get(m));
        }
        Map<String, Object> source = this.client.get(new GetRequest(ESUtil.a01Index, personid), RequestOptions.DEFAULT).getSource();
        if (source != null) {
            A01 a01s = ESUtil.useObjectMapper(source);
            a01s.setA19List(listA19ES);
            this.client.index(new IndexRequest(ESUtil.a01Index).id(a01s.getFlowid()).source(JSON.toJSONString(a01s), XContentType.JSON), RequestOptions.DEFAULT);
        }
        return R.ok();
    }

    @PostMapping({"/updateList"})
    @ApiOperation("简历批量更新")
    public R updateList(@RequestBody List<A19> entityList) {
        this.a19Service.updateBatchById(entityList);
        return R.ok();
    }

    @PostMapping({"/updateOrder"})
    @ApiOperation("简历批量排序")
    public R updateOrder(@RequestBody A19Extend entity) {
        List<A19> entityList = entity.getList();
        if (entityList.size() > 0) {
            for (int i = 0; i < entityList.size(); i++) {
                this.a19Service.updateById(entityList.get(i));
            }
        }
        A01 a01 = new A01();
        a01.setFlowid(entity.getPersonid());
        a01.setA0183(entity.getA0183());
        this.a01Service.updateById(a01);
        return R.ok();
    }

    @PostMapping({"/delete"})
    @SysLog(value = "删除现职信息", target = "A01", set = "A19", type = DateUtil.SUB_MONTH)
    @ApiOperation("简历删除")
    @A19Tag("删除")
    public R delete(@RequestBody String[] flowIds) {
        this.a19Service.getBaseMapper().deleteBatchIds(Arrays.asList(flowIds));
        return R.ok();
    }

    @GetMapping({"/updatea0177b"})
    public R updatea0177b(@RequestParam String personid, @RequestParam String a0183) {
        return R.ok().put("a01", (Object) this.a19Service.update_A0177b(personid, a0183));
    }

    @GetMapping({"/saveA1955"})
    @ApiOperation("保存简称")
    public R saveA1955(@RequestParam String personid, @RequestParam String a1955, @RequestParam String a0183b) {
        A01 a01 = (A01) this.a01Service.getBaseMapper().selectById(personid);
        this.a19Service.update_A01(a01, a1955, a0183b);
        try {
            A01 a011 = new A01();
            A01 a01old = new A01();
            a011.setA0183(a1955);
            a01old.setA0183(a01.getA0183());
            SysLogEntity sysLog = new SysLogEntity();
            sysLog.setOperation("保存现职简称");
            sysLog.setOperationtable("A01");
            sysLog.setOperationset("A01");
            a011.setA0171(new byte[0]);
            sysLog.setParams(JSON.toJSONString(a011).toLowerCase());
            sysLog.setOperationtype(1);
            a01old.setA0171(new byte[0]);
            sysLog.setOldparams(JSON.toJSONString(a01old).toLowerCase());
            sysLog.setMethod("saveA1955");
            sysLog.setTargetid(personid);
            sysLog.setIp(IPUtils.getIpAddr(HttpContextUtils.getHttpServletRequest()));
            sysLog.setUsername(SecurityUtils.getUsername());
            sysLog.setTime(100L);
            sysLog.setCreateDate(new Date());
            this.sysLogService.getBaseMapper().insert(sysLog);
        } catch (Exception e) {
        }
        return R.ok();
    }

    public List<A19> jianlifenge() throws IOException {
        List<A01> a01List = this.a01Service.getBaseMapper().selectByMap(new HashMap());
        List<A19> a19List = new ArrayList<>();
        for (int i = 0; i < a01List.size(); i++) {
            try {
                a19List.addAll(this.a19Service.praseResume(a01List.get(i).getA0177()));
            } catch (Exception ex) {
                System.out.println("parse resume error:" + ex.getMessage());
            }
        }
        new TestTextUtil();
        TestTextUtil.writeFile(a19List);
        return a19List;
    }

    @PostMapping({"/initList/{personId}"})
    @ApiOperation("简历编辑界面列表初始化")
    public R initList(@PathVariable("personId") String personId) {
        List<A19> list = this.a19Service.queryInitList(personId);
        for (int t = 0; t < list.size(); t++) {
            try {
                list.get(t).getA1905().setHours(10);
            } catch (Exception e) {
            }
            try {
                list.get(t).getA1910().setHours(10);
            } catch (Exception e2) {
            }
        }
        return R.ok().put("data", (Object) list);
    }

    @PostMapping({"/segmentResume"})
    @ApiOperation("简历分割接口")
    public R segmentResume(@RequestBody Map<String, Object> map) throws IOException {
        String resumeStr = map.get("resumeStr").toString();
        List<A19> a19List = new ArrayList<>();
        try {
            a19List.addAll(this.a19Service.praseResume(resumeStr));
        } catch (Exception ex) {
            System.out.println("parse resume error:" + ex.getMessage());
        }
        return R.ok().put("data", (Object) a19List);
    }

    @PostMapping({"/segmentResumeAndInitList"})
    @ApiOperation(value = "简历分割整合初始化数据接口", notes = "personId:人员ID;resumeStr;简历数据;")
    public R segmentResumeAndInitList(@RequestBody Map<String, Object> map) throws IOException {
        map.get("personId").toString();
        String resumeStr = map.get("resumeStr").toString();
        List<A19> a19List = new ArrayList<>();
        try {
            a19List.addAll(this.a19Service.praseResume(resumeStr));
        } catch (Exception ex) {
            System.out.println("parse resume error:" + ex.getMessage());
        }
        for (int t = 0; t < a19List.size(); t++) {
            try {
                a19List.get(t).getA1905().setHours(10);
            } catch (Exception e) {
            }
            try {
                a19List.get(t).getA1910().setHours(10);
            } catch (Exception e2) {
            }
        }
        return R.ok().put("data", (Object) ((List) a19List.stream().distinct().collect(Collectors.toList())));
    }

    /*  JADX ERROR: JadxRuntimeException in pass: BlockProcessor
        jadx.core.utils.exceptions.JadxRuntimeException: Unreachable block: B:11:0x0089
        	at jadx.core.dex.visitors.blocks.BlockProcessor.checkForUnreachableBlocks(BlockProcessor.java:86)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.processBlocksTree(BlockProcessor.java:52)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.visit(BlockProcessor.java:44)
        */
    @PostMapping({"/initA19BList"})
    @ApiOperation("初始化简历数据(A19B)")
    public R initA19BList() {
        /*
            r4 = this;
            r0 = r4
            com.tdqy.cadre.modular.profess.service.A01Service r0 = r0.a01Service
            java.util.List r0 = r0.selectA0177List()
            r5 = r0
            r0 = 0
            r6 = r0
        L_0x000c:
            r0 = r6
            r1 = r5
            int r1 = r1.size()
            if (r0 >= r1) goto L_0x00c8
            r0 = r5
            r1 = r6
            java.lang.Object r0 = r0.get(r1)     // Catch: Exception -> 0x00be
            java.util.Map r0 = (java.util.Map) r0     // Catch: Exception -> 0x00be
            java.lang.String r1 = "FLOWID"
            java.lang.Object r0 = r0.get(r1)     // Catch: Exception -> 0x00be
            java.lang.String r0 = r0.toString()     // Catch: Exception -> 0x00be
            r7 = r0
            r0 = r5
            r1 = r6
            java.lang.Object r0 = r0.get(r1)     // Catch: Exception -> 0x00be
            java.util.Map r0 = (java.util.Map) r0     // Catch: Exception -> 0x00be
            java.lang.String r1 = "A0177"
            java.lang.Object r0 = r0.get(r1)     // Catch: Exception -> 0x00be
            java.lang.String r0 = r0.toString()     // Catch: Exception -> 0x00be
            r8 = r0
            r0 = r8
            if (r0 == 0) goto L_0x00b8
            r0 = r8
            java.lang.String r0 = r0.trim()     // Catch: Exception -> 0x00be
            java.lang.String r1 = ""
            if (r0 == r1) goto L_0x00b8
            r0 = r4
            com.tdqy.cadre.modular.profess.service.A19Service r0 = r0.a19Service     // Catch: Exception -> 0x00be
            r1 = r7
            int r0 = r0.deleteA19BById(r1)     // Catch: Exception -> 0x00be
            java.util.ArrayList r0 = new java.util.ArrayList     // Catch: Exception -> 0x00be
            r1 = r0
            r1.<init>()     // Catch: Exception -> 0x00be
            r9 = r0
            r0 = r8
            java.lang.String r1 = "\n\r"
            java.lang.String r2 = "\n\n"
            java.lang.String r0 = r0.replace(r1, r2)     // Catch: Exception -> 0x00be, Exception -> 0x0089
            r8 = r0
            r0 = r4
            com.tdqy.cadre.modular.profess.service.A19Service r0 = r0.a19Service     // Catch: Exception -> 0x00be, Exception -> 0x0089
            r1 = r8
            java.util.List r0 = r0.praseResume(r1)     // Catch: Exception -> 0x00be, Exception -> 0x0089
            r10 = r0
            r0 = r9
            r1 = r10
            boolean r0 = r0.addAll(r1)     // Catch: Exception -> 0x00be, Exception -> 0x0089
            goto L_0x00a8
        L_0x0089:
            r10 = move-exception
            java.io.PrintStream r0 = java.lang.System.out     // Catch: Exception -> 0x00be
            java.lang.StringBuilder r1 = new java.lang.StringBuilder     // Catch: Exception -> 0x00be
            r2 = r1
            r2.<init>()     // Catch: Exception -> 0x00be
            java.lang.String r2 = "parse resume error:"
            java.lang.StringBuilder r1 = r1.append(r2)     // Catch: Exception -> 0x00be
            r2 = r10
            java.lang.String r2 = r2.getMessage()     // Catch: Exception -> 0x00be
            java.lang.StringBuilder r1 = r1.append(r2)     // Catch: Exception -> 0x00be
            java.lang.String r1 = r1.toString()     // Catch: Exception -> 0x00be
            r0.println(r1)     // Catch: Exception -> 0x00be
        L_0x00a8:
            r0 = r4
            com.tdqy.cadre.modular.profess.service.A19Service r0 = r0.a19Service     // Catch: Exception -> 0x00be
            r1 = r9
            r2 = r7
            int r0 = r0.saveA19BByList(r1, r2)     // Catch: Exception -> 0x00be
            goto L_0x00bb
        L_0x00b8:
            goto L_0x00c2
        L_0x00bb:
            goto L_0x00c2
        L_0x00be:
            r7 = move-exception
            goto L_0x00c2
        L_0x00c2:
            int r6 = r6 + 1
            goto L_0x000c
        L_0x00c8:
            java.lang.String r0 = "简历处理完毕"
            com.tdqy.cadre.core.utils.R r0 = com.tdqy.cadre.core.utils.R.ok(r0)
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tdqy.cadre.modular.profess.controller.A19Controller.initA19BList():com.tdqy.cadre.core.utils.R");
    }

    /*  JADX ERROR: JadxRuntimeException in pass: BlockProcessor
        jadx.core.utils.exceptions.JadxRuntimeException: Unreachable block: B:27:0x0110
        	at jadx.core.dex.visitors.blocks.BlockProcessor.checkForUnreachableBlocks(BlockProcessor.java:86)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.processBlocksTree(BlockProcessor.java:52)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.visit(BlockProcessor.java:44)
        */
    @PostMapping({"/saveList"})
    @org.springframework.transaction.annotation.Transactional
    public R saveList(@RequestBody JSONObject r9) {
        /*
        // Method dump skipped, instructions count: 438
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tdqy.cadre.modular.profess.controller.A19Controller.saveList(com.alibaba.fastjson.JSONObject):com.tdqy.cadre.core.utils.R");
    }

    /*  JADX ERROR: JadxRuntimeException in pass: BlockProcessor
        jadx.core.utils.exceptions.JadxRuntimeException: Unreachable block: B:37:0x0195
        	at jadx.core.dex.visitors.blocks.BlockProcessor.checkForUnreachableBlocks(BlockProcessor.java:86)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.processBlocksTree(BlockProcessor.java:52)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.visit(BlockProcessor.java:44)
        */
    @PostMapping({"/saveListAndResumeString"})
    @org.springframework.transaction.annotation.Transactional
    @ApiOperation(value = "解析简历列表保存(按照界面显示文本保存)", notes = "personId:人员ID;a0177:旧简历;a0177b:自动简历;a0199:委员经历；a0177bflag:是否启用原始简历(0不启用1启用);resumelist:列表数据")
    public R saveListAndResumeString(@RequestBody JSONObject r6) {
        /*
        // Method dump skipped, instructions count: 684
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tdqy.cadre.modular.profess.controller.A19Controller.saveListAndResumeString(com.alibaba.fastjson.JSONObject):com.tdqy.cadre.core.utils.R");
    }

    @PostMapping({"/formatResumeString"})
    @ApiOperation(value = "列表解析成简历字符串", notes = "resumelist:列表数据")
    public R formatResumeString(@RequestBody JSONObject json) {
        System.out.println("接受参数====== " + json);
        return R.ok().put("data", (Object) this.a19Service.fromatResume(json));
    }

    /*  JADX ERROR: JadxRuntimeException in pass: BlockProcessor
        jadx.core.utils.exceptions.JadxRuntimeException: Unreachable block: B:27:0x0107
        	at jadx.core.dex.visitors.blocks.BlockProcessor.checkForUnreachableBlocks(BlockProcessor.java:86)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.processBlocksTree(BlockProcessor.java:52)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.visit(BlockProcessor.java:44)
        */
    @PostMapping({"/formatResumeString_bak"})
    @ApiOperation(value = "列表解析成简历字符串", notes = "resumelist:列表数据")
    public R formatResumeString_bac(@RequestBody JSONObject r8) {
        /*
        // Method dump skipped, instructions count: 706
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tdqy.cadre.modular.profess.controller.A19Controller.formatResumeString_bac(com.alibaba.fastjson.JSONObject):com.tdqy.cadre.core.utils.R");
    }

    @PostMapping({"/backResumeData"})
    public R backResumeData(@RequestBody String personId) {
        String a0177B = ((A01) this.a01Service.getBaseMapper().selectById(personId)).getA0177();
        this.a19Service.deleteA19BById(personId);
        return R.ok().put("olddata", (Object) a0177B);
    }

    @PostMapping({"/resumeDataSort"})
    @ApiOperation(value = "简历列表排序", notes = "resumelist:列表数据")
    public R resumeDataSort(@RequestBody JSONObject json) {
        JSONArray resumeArray = json.getJSONArray("resumelist");
        for (int a = 0; a < resumeArray.size(); a++) {
            JSONObject obj = (JSONObject) resumeArray.get(a);
            try {
                String startdate = obj.get("a1905").toString();
                if (!(startdate == null || startdate == "")) {
                    startdate = startdate.replace(".", "-") + "-01 10:00:00";
                }
                obj.put("a1905", startdate);
            } catch (Exception e) {
            }
            try {
                String enddate = obj.get("a1910").toString();
                if (!(enddate == null || enddate == "")) {
                    enddate = enddate.replace(".", "-") + "-01 10:00:00";
                }
                obj.put("a1910", enddate);
            } catch (Exception e2) {
            }
        }
        List<A19> a19List = JSONObject.parseArray(JSONArray.toJSONString(resumeArray), A19.class);
        Collections.sort(a19List, new Comparator<A19>() { // from class: com.tdqy.cadre.modular.profess.controller.A19Controller.2
            public int compare(A19 o1, A19 o2) {
                int flag;
                try {
                    if (o1.getA1905().equals(o2.getA1905())) {
                        flag = o1.getA1910().compareTo(o2.getA1910());
                    } else {
                        flag = o1.getA1905().compareTo(o2.getA1905());
                    }
                    return flag;
                } catch (Exception e3) {
                    return 0;
                }
            }
        });
        return R.ok().put("data", (Object) a19List);
    }

    public R checkAuthByPersonid(@PathVariable("userId") String userId, @PathVariable("personId") String personId) {
        String result;
        if (userId.equals("1")) {
            result = "1";
        } else {
            result = this.a19Service.checkAuthByPersonid(userId, personId);
        }
        return R.ok().put("result", (Object) result);
    }

    @PostMapping({"/checkAuthByUnitid"})
    @ApiOperation(value = "查询单位信息的读写权限", notes = "userId:登录用户ID;unitId:部门信息ID;personId:人员信息ID;result:结果0 只读，1读写")
    public R checkAuthByUnitid(@RequestBody JSONObject json) {
        String result;
        String userId = json.get("userId").toString();
        String personId = "";
        try {
            personId = json.get("personId").toString();
        } catch (Exception e) {
        }
        String unitId = "";
        try {
            unitId = json.get("unitId").toString();
        } catch (Exception e2) {
        }
        if (userId.equals("1")) {
            result = "1";
        } else {
            String result_p = this.a19Service.checkAuthByPersonid(userId, personId);
            String result_u = this.a19Service.checkAuthByUnitid(userId, unitId);
            if (result_p.equals("1") || result_u.equals("1")) {
                result = "1";
            } else {
                result = "0";
            }
            if (personId.equals("add") || unitId.equals("add")) {
                result = "1";
            }
            if (personId != null && this.a19Service.checkIsNullPositionByPersonid(personId).equals("0")) {
                result = "1";
            }
        }
        return R.ok().put("result", (Object) result);
    }

    @PostMapping({"/removeTeam"})
    @ApiOperation(value = "班子成员移除功能", notes = "a1915:部门信息ID;personid:人员信息ID")
    public R checkAuthByUnitid(@RequestBody Map<String, Object> map) {
        map.put("a1945", "0");
        this.a19Service.updateByUidAndPid(map);
        return R.ok();
    }
}
